#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <string>
#include <stack>
#include <set>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;

struct node{
    ll x,y;
};
node a[110000],b[110000];
ll cnt[110];
bool cmp(node a,node b){
    if(a.x==b.x){
        return a.y>b.y;
    }
    return a.x>b.x;
}
int main()
{
    IOS;
    ll n,m;
    while(cin>>n>>m){
        memset(cnt,0,sizeof(cnt));
        for(ll i=1;i<=n;i++){
            cin>>a[i].x>>a[i].y;
        }
        for(ll i=1;i<=m;i++){
            cin>>b[i].x>>b[i].y;
        }
        sort(a+1,a+1+n,cmp);
        sort(b+1,b+1+m,cmp);
        ll ans=0,num=0;
        ll i=1,j=1;
        for(j=1;j<=m;j++){
            while(i<=n&&a[i].x>=b[j].x){
                cnt[a[i].y]++;
                i++;
            }
            for(ll y=b[j].y;y<=100;y++){
                if(cnt[y]){
                // cout<<"test"<<endl;
                cnt[y]--;
                num++;
                ans+=(500*b[j].x+2*b[j].y);
                break;
                }
            }
            // cout<<ans<<endl;
        }
        cout<<num<<" "<<ans<<endl;
    }
    getchar();
    getchar();
    return 0;
}
